#include "Drag.h"

void Drag::updateForce(Particle* particle, float frameTime)
{
	D3DXVECTOR3 force = particle->velocity;

	// Calculate the total drag coefficient.
	float dragCoeff = D3DXVec3Length(&force);
	// Check the drag coefficient will reduce velocity.
	if (dragCoeff <= 0.0f) return;
	dragCoeff = k1 * dragCoeff + k2 * dragCoeff * dragCoeff;

	// Calculate the final force and apply it.
	D3DXVec3Normalize(&force, &force);
	force *= -dragCoeff;
	particle->force += force;
}